class Alg2{
    //T一定是实现了Comparable接口的,此时只要是实现了Comparable接口的都可以传过去
    public <T extends Comparable<T>> T getmax(T[] array){  //泛型方法
        T max = array[0];
        for (int i = 1; i < array.length; i++) {
            if(array[i].compareTo(max)>0){
                max = array[i];
            }
        }
        return max;
    }
}


public class test2 {
    public static void main(String[] args) {
        Alg2 alg2 = new Alg2();
        Integer[] array = {1,2,3,4,5,6};
        Integer getmax = alg2.getmax(array);
        System.out.println(getmax);
    }
}
